package com.wuzf.navigation_test.utils;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.DisplayMetrics;

public class PxUtil {

    /**
     * dp转px
     *
     * @param size
     * @return
     */
    public static int dp2px(int size) {
        Resources resources = MyApplication.getApplication().getResources();
        DisplayMetrics metrics = resources.getDisplayMetrics();
        return (int) (metrics.density * size + 0.5f);
    }


    public static int getScreenWidth() {
        Resources resources = MyApplication.getApplication().getResources();
        DisplayMetrics metrics = resources.getDisplayMetrics();
        return metrics.widthPixels;
    }

    public static int getScreenHeight() {
        Resources resources = MyApplication.getApplication().getResources();
        DisplayMetrics metrics = resources.getDisplayMetrics();
        return metrics.heightPixels;
    }
}
